#include <stdio.h>
#include <stdlib.h>

#define MAX_LENGTH 131072

unsigned char buf[MAX_LENGTH];

int main(int argc, char** argv)
{

	if (argc == 7 && !strcmp(argv[1], "-f") && !strcmp(argv[3], "-o") && !strcmp(argv[5], "-s")) {
		FILE *fi = fopen(argv[2], "rb");
		fread(buf, 1, sizeof(buf), fi);
		fclose(fi);

		int sz = atoi(argv[6]) << 2, i, j;
		FILE *fo = fopen(argv[4], "w");
		for (i=0; i<sz; i+=4) {
			for (j=0; j<4; ++j)
				fprintf(fo, "%02x", buf[i + j]);
			fprintf(fo, "\n");
		}
		fclose(fo);
	} else
		puts("Invalid command.");

	return 0;
}

